Assembly keep getting seg fault when working with stack [migrated]

Posted by user973917 on Programmers See other posts from Programmers or by user973917
Published on 2012-10-14T16:23:44Z Indexed on 2012/10/14 21:50 UTC
Read the original article Hit count: 717

Filed under:
|

I'm trying to learn assembly and have found that I keep getting segfaults when trying to push/pop data off of the stack. I've read a few guides and know how the stack works and how to work with the stack; but don't know why I keep getting the error.

Can someone help?

segment .data
        myvar: db "hello world", 0xA0, 0
        myvarL: equ $-myvar

segment .text
        global _start

_start:
        push ebp
        mov ebp, esp
        push myvarL
        push myvar
        call _hworld

_hworld:
        mov eax, 4
        mov ebx, 1
        mov ecx, [ebp+4]
        mov edx, [ebp+8]
        pop ebp
        int 0x80
        ret

I'm assuming that the +4 is 32 bits, then +8 is 64 bits. It isn't really clear to me why this way is being done on some of the guides I've read. I would assume that myvar is 13 bits?

© Programmers or respective owner

Related posts about assembly

Related posts about stack